PLATFORM ?= $(shell uname)

CC = gcc
SRCS = main.c view.c server.c client.c
LIBS = -lpthread
CFLAGS +=

SRC_DIR = ./src
BIN_DIR = ./bin

	EXE = .out
	SRCS += socket.c string_value.c


OBJS = $(SRCS:%.c=%.o)
BIN = mychatroom$(EXE)

all: bin

run: bin
	cd $(BIN_DIR) && ./$(BIN)

clean:
	@cd $(SRC_DIR) && rm -f $(OBJS)

bin: $(BIN_DIR)/$(BIN)

$(BIN_DIR)/$(BIN): $(OBJS:%=$(SRC_DIR)/%)
	$(CC) -o $@ $^ $(LIBS)

%.o: %.c
	$(CC) $(CFLAGS) -o $@ -c $<

.PHONY: all bin run clean
